package com.linewell.controller;

import com.linewell.entity.Focus;
import com.linewell.service.IFocusService;
import com.linewell.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Title: ssm2
 * @description: 关注管理控制器
 * @author: hyuhuang@linewell.com
 * @since:2018/2/06
 */
@Controller
public class FocusController {
    @Autowired
    IFocusService focusService;
    /**
     * @descripition  查询关注标签
     * @author hyuhuang@linewell.com
     * @date 2018/2/27 10:44
     * @param userId, model
     * @return java.lang.String
     */
    @RequestMapping("/follow")
    public String follow(@RequestParam("userId") Long userId, Model model){
        Focus focus = focusService.selectAllFocus(userId);
        model.addAttribute("focus",focus);
        return "follow";
    }
    /**
     * @descripition  关注他人
     * @author hyuhuang@linewell.com
     * @date 2018/3/25 17:50
     * @param
     * @return com.linewell.utils.Msg
     */
    @RequestMapping("/focus")
    @ResponseBody
    public Msg attention(@RequestParam("userId") Long userId,@RequestParam("focusId") Long focusId){
        return focusService.attention(userId,focusId);
    }

    /**
    * @descripition 判断是否关注
    * @author hyuhuang@linewell.com
    * @date 2018/5/5
    * @param userId focusId
    * @return com.linewell.utils.Msg
    */
    @RequestMapping("/isFocus")
    @ResponseBody
    public Msg isFocus(@RequestParam("userId") Long userId,@RequestParam("focusId") Long focusId){
        return focusService.selectFocus(userId,focusId);
    }

    /**
     * @Description 获得用户的标签
     * @author hyuhuang@linewell.com
     * @date 2018/4/14
     * @param userId
     * @return com.linewell.utils.Msg
     */
    @RequestMapping("/getUserTag")
    @ResponseBody
    public Msg getUserTag(@RequestParam("userId") Long userId){
        return focusService.getUserTag(userId);
    }


    /**
    * @descripition 获得推荐的文章
    * @author hyuhuang@linewell.com
    * @date 2018/5/5
    * @param tagId
    * @return com.linewell.utils.Msg
    */
    @RequestMapping("/getRecommendArticle")
    @ResponseBody
    public Msg getRecommendArticle(@RequestParam("tagId") int tagId){
        return focusService.getRecommendArticle(tagId);
    }
}
